require "active_record"

##
# This class is used for getting the user from the wordpress database
# 
# == Examples:
#   User.find(1).name
# The above will find the user with id of 1 and retrieve their display name

class User < ActiveRecord::Base
  
  class << self
    def inspect
      "User(id: integer, name: string, username: string, email: string)"
    end
  end
  
	set_table_name :wp_users
	set_primary_key :ID
	
	has_many :settings
	has_many :pages, :foreign_key => :post_author
	has_many :posts, :foreign_key => :post_author
	has_many :comments, :foreign_key => :user_id
	
	alias_attribute :name, :display_name
	alias_attribute :username, :user_login
	alias_attribute :email, :user_email
	
	def inspect
	  "#<User id: #{id}, name: \"#{name}\", username: \"#{username}\", email: \"#{email}\">"
  end
end